package com.mz.ozy.utils;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.DisplayMetrics;

import com.mz.ozy.constants.Constants;

import java.util.Locale;

public class LanguageUtils {

    public static void switchLanguage(Context context) {
        //设置应用语言类型
        Resources resources = context.getResources();
        Configuration config = resources.getConfiguration();
        DisplayMetrics dm = resources.getDisplayMetrics();
        if (SPUtils.getInstance(context).getString(Constants.SPName.LANGUAGE, "zhmsg").contains("zhmsg")) {
            config.locale = Locale.SIMPLIFIED_CHINESE;
        } else {
            config.locale = Locale.ENGLISH;
        }
        resources.updateConfiguration(config, dm);

    }

}
